package cn.anecansaitin.industrialization_expansion.api.common.event;

import cn.anecansaitin.industrialization_expansion.common.item.crafting.ModifiedToolRecipe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.eventbus.api.Event;

import java.util.List;

/**
 * 自定义工具组合事件
 */
public class ToolAssembleEvent extends Event {

    /**
     * 用于合成工具的模块
     */
    protected final NonNullList<ItemStack> modules;

    /**
     * 合成的配方
     */
    protected final ModifiedToolRecipe recipe;

    protected ToolAssembleEvent(ModifiedToolRecipe recipe, NonNullList<ItemStack> modules) {
        this.recipe = recipe;
        this.modules = modules;
    }

    public List<ItemStack> getModules() {
        return modules;
    }

    public ModifiedToolRecipe getRecipe() {
        return recipe;
    }

    /**
     * 在合成工具前
     */
    public static class Pre extends ToolAssembleEvent {
        public Pre(ModifiedToolRecipe recipe, NonNullList<ItemStack> modules) {
            super(recipe, modules);
        }
    }

    /**
     * 在工具合成后
     */
    public static class Post extends ToolAssembleEvent {
        /**
         * 合成后的工具
         */
        private ItemStack result;

        public Post(ModifiedToolRecipe recipe, NonNullList<ItemStack> modules, ItemStack result) {
            super(recipe, modules);
            this.result = result;
        }

        public ItemStack getResultTool() {
            return result;
        }

        public void setResultTool(ItemStack result) {
            this.result = result;
        }
    }
}
